﻿// See https://aka.ms/new-console-template for more information

using Data.Model.SQLite;

using System.Reflection.Metadata.Ecma335;
using System.Reflection;
using System.Text;
using UnitTest;
using System.Security.Cryptography;
using DataService.Data;
using DataService.Core.Common;
using UnitTest.Excel;
using UnitTest.Other;
using Mysqlx.Expr;
using DataService.Core.ServiceDTO.Const;
using System.IO;
using System.Xml.Linq;
using DataDriven;
using System.Text.RegularExpressions;
using UnitTest.TestOCR;
using DataService.Office.Excel;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.EMMA;
using DocumentFormat.OpenXml.Wordprocessing;
using UnitTest.HttpClient;





TestIOC testIOC = new TestIOC();
testIOC.TestScope();
return;
TestSqllite testSqllite1 = new TestSqllite();
testSqllite1.Insert_1();
return;

TestMySql testMySql = new TestMySql();
testMySql.Insert_1();
Console.WriteLine("完成");
return;

//var fieldIfno = typeof(TestIndexTable).GetProperty("Id").GetCustomAttribute<FieldndexAttribute>();

//var fieldIndex = typeof(TestIndexTable).GetProperty("Id").GetMemberInfoAttribute<FieldndexAttribute>();
//Console.WriteLine(fieldIfno.Value);
//var log = DataService.Core.Collections.PoolFactory.StringBuilder.Get();
//Console.WriteLine(Environment.ProcessorCount);
//int temp1 = 5;
//int temp2 = 8;
//int temp3 = 5;
//Interlocked.CompareExchange(ref temp1, temp2, temp3);
//Console.WriteLine($"temp1：{temp1},temp2：{temp2},temp3{temp3}");
//int temp4=Interlocked.CompareExchange(ref temp1, temp2, temp3);
//Console.WriteLine($"temp1：{temp1},temp2：{temp2},temp3{temp3},temp4：{temp4}");
//Console.ReadKey();
//#region 雪花
//TestSnowflake testSnowflake = new TestSnowflake();
//testSnowflake.Test2();

//Console.ReadKey();
//return;
//#endregion


//var testFeiJiangOCR = new TestFeiJiangOCR();
//testFeiJiangOCR.TestLoaclFile();

//Console.WriteLine("完成");
//return;



//object o = new object();
//Task task = new Task(() =>
//{
//    Monitor.Enter(o);
//    Console.WriteLine("等待信号" + DateTime.Now);
//    Thread.Sleep(2 * 1000);
//    Monitor.Wait(o, 3);
//    Console.WriteLine("Wait后:" + DateTime.Now);
//    Monitor.Exit(o);
//});
//task.Start();

//Task task1 = new Task(() =>
//{
//    Monitor.Enter(o);
//    Console.WriteLine("发送信息" + DateTime.Now);
//    Thread.Sleep(10 * 1000);
//    Monitor.PulseAll(o);
//    Console.WriteLine("发送信号后：" + DateTime.Now);
//    Monitor.Exit(o);
//});
//task1.Start();

//Task.WaitAll(task, task1);
//Console.WriteLine("完成");
//return;

//TestCsv testCsv = new TestCsv();
//testCsv.ReadTest();
//Console.WriteLine("完成");
//return;

TestExcel testExcel = new TestExcel();
testExcel.WriteExcel();
Console.WriteLine("完成");
return;
//return;



#region 测试生成模型文件


TestModelCode testModelCode = new TestModelCode();
testModelCode.TestFromMSSQL_All();
Console.WriteLine("完成");
return;
#endregion

string tempUrl = "https://edesign.dimpt.com:16727/MadeLPVideoInfo.aspx?lpParam=mcGihRFIxq/0yZEnhttpZiz";
if (tempUrl.StartsWith("http"))
{
    tempUrl = tempUrl.Replace("http://", "https://");
}
Console.WriteLine(tempUrl.StartsWith("http"));
return;



int a = 1;
double b = a / (double)1024;
Console.WriteLine((int)Math.Ceiling(b));
return;
#region 测试定时器
////TestTimerHelper.Timer_1();
//Console.ReadKey();
#endregion


#region 测试生成模型文件


//TestModelCode testModelCode = new TestModelCode();
//testModelCode.TestFromMSSQL_All();
//Console.WriteLine("完成");
//return;
#endregion

#region 其他测试
DirectoryHelper.CopyDirectoryFiles(@"D:\", @"D:\新建文件夹");

#endregion
#region 测试缓存

//TestCache testCache = new TestCache();
//testCache.TestSetRedis();
////Thread.Sleep(80 * 1000);
//testCache.TestGetRedis();
//Console.WriteLine("Redis完成");
//Console.ReadKey();
#endregion
#region 测试序列化/反序列化
//TestJson testJson = new TestJson();
//testJson.TestJson1();
////testJson.ListToJson();
//Console.ReadKey();

#endregion
#region 测试调用链
//TestStackFrame.Test1();
//Console.ReadKey();

#endregion

#region 测试释放对象
//TestDisposable testDisposable = new TestDisposable();
//testDisposable.DoDispose2();
//Console.WriteLine("释放完成");
//Console.ReadKey();
#endregion

#region 生成实体模型（Model类）
//TestModelCode ModelCode = new TestModelCode();
//ModelCode.TestFromMSSQL_All();
////ModelCode.TestFormSqlite();
//Console.WriteLine("结束");
//Console.ReadKey();

#endregion
#region 从MSSQLSERVER数据库，生成模型文件（模型文件为sqlite）
//TestSqllite testSqllite = new TestSqllite();
//testSqllite.TestCreateModelFile();
//Console.WriteLine("完成");
//Console.ReadKey();
#endregion
#region 测试达梦

TestDM testDM = new TestDM();
//testDM.CreateTable();
//testDM.CreateModel();
//testDM.TestDMBeatchInsert();
testDM.ReadData();
Console.WriteLine("完成");
return;
#endregion

#region 向指定数据库创建表结构
//TestDataBase testDataBase = new TestDataBase();
//testDataBase.CreateTableBase();
//Console.WriteLine("完成");
//return;
#endregion

#region Sqlserver添加/分页查询
//TestSqlserver testSqlserver = new TestSqlserver();
//List<Task> tasks2 = new List<Task>();
//for (int i = 0; i < 10; i++)
//{
//    tasks2.Add(Task.Run(() =>
//    {
//        Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
//        testSqlserver.TestBeatchInsert();
//    }));

//}
//Task.WaitAll(tasks2.ToArray());

//Console.WriteLine("sqlserver添加完成");
//return;

#endregion
#region sqlite测试分页查询/添加
TestSqllite testSqllite = new TestSqllite();
//List<Task> tasks = new List<Task>();
//for (int i = 0; i < 10; i++)
//{
//    tasks.Add(Task.Run(() =>
//    {
//        Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
//        testSqllite.BeatchInsert();
//    }));

//}
//Task.WaitAll(tasks.ToArray());
testSqllite.ReadData();
Console.ReadKey();
return;
#endregion



#region 测试MySql

//TestMySql testMySql = new TestMySql();
////testMySql.CreateModel();
//testMySql.Insert();
////testMySql.ReadData();
//Console.WriteLine("Mysql结束");
//Console.ReadKey();
#endregion




Snowflake snowflake = new Snowflake();
for (int i = 0; i < 10; i++)
{
    long value = snowflake.NewId();
    Console.WriteLine(value + "长度：" + value.ToString().Length);
}
Console.ReadKey();




int _exchangeLock = 0;

Console.WriteLine(Interlocked.Exchange(ref _exchangeLock, 2));
Console.WriteLine(_exchangeLock);
Console.ReadKey();
List<string> strs = new List<string>();
strs.Add("111");
strs.Add("222");
strs.Add("333");
Console.WriteLine(string.Join(" AND ", strs));
Console.ReadKey();

TestSqlserver sqlserverTest1 = new TestSqlserver();
sqlserverTest1.TestCreateTable();
Console.WriteLine("完成");
Console.ReadKey();

//TestPath testPath = new TestPath();
//testPath.TestBasePath();
//Console.ReadKey();

//TestDisposable testDisposable = new TestDisposable();
//testDisposable.DoDispose1();
//SnowflakeTest.TestTryParse();

//DateTime StartTimestamp= new DateTime(1970, 1, 1);
//var _msStart = (Int64)(DateTime.Now - StartTimestamp).TotalMilliseconds;
//Console.WriteLine($"{_msStart}***{(_msStart << 22)}");
//Console.WriteLine("1659298725912".Length + "***" + "6959603283287605248".Length);
//Console.WriteLine($"{6959603283287605248 >> 22}");

//DBFactroy.DBMangerFactory.Create(DatabaseType.SqlServer);
//TestStackFrame.Test2();

//Base1 testDataBase = new TestDataBase("传入参数");
//testDataBase.TestWrite();


//SQLiteTest SQLite = new SQLiteTest();
//SQLite.TestProvider();

